<template>
  <div id="home">
    <el-container class="page-container">
      <el-header>

        <HomeHeader></HomeHeader>

      </el-header>

      <el-container>
        <el-aside v-show="showAside" width="200px" class="aside-transition">

          <AsideMenu @foldchange="getfoldstate"></AsideMenu>

        </el-aside>
        <el-main>

          <RouterView></RouterView>

        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import AsideMenu from '../components/home/MagAsideMenu.vue';
import HomeHeader from '../components/home/HomeHeader.vue';

const showAside = ref(true);

const getfoldstate = () => {
  console.log("父组件接收到了数据", showAside.value);
  showAside.value = !showAside.value;

}


</script>

<style scoped lang="scss">
#home {
  height: 100%;
  background-color: red;

  .page-container {
    background-color: rgb(255, 230, 234);
    width: 100%;
    height: 100%;

    .el-header {
      height: 68px;
      background-color: #333744;
    }

    .el-aside {
      background-color: #333744;
    }

    .el-main {
      background-color: rgb(245, 247, 255);
    }

    // 定义拉入和拉出过渡效果
    .aside-transition {
      transition: transform 0.3s;
    }

    .aside-enter-active,
    .aside-leave-active {
      /* 设置初始位置和结束位置 */
      transform: translateX(-100%);
    }

    .aside-enter-to,
    .aside-leave-from {
      /* 设置中间位置 */
      transform: translateX(0);
    }
  }
}
</style>
